package com.aurora.blog.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.aurora.common.log.annotation.Log;
import com.aurora.common.log.enums.BusinessType;
import com.aurora.common.security.annotation.RequiresPermissions;
import com.aurora.blog.domain.BlogSharesConfig;
import com.aurora.blog.service.IBlogSharesConfigService;
import com.aurora.common.core.web.controller.BaseController;
import com.aurora.common.core.web.domain.AjaxResult;
import com.aurora.common.core.utils.poi.ExcelUtil;
import com.aurora.common.core.web.page.TableDataInfo;

/**
 * 分享类型配置Controller
 * 
 * @author aurora
 * @date 2024-06-04
 */
@RestController
@RequestMapping("/blogShareConfig")
public class BlogSharesConfigController extends BaseController
{
    @Autowired
    private IBlogSharesConfigService blogSharesConfigService;

    /**
     * 查询分享类型配置列表
     */
    @RequiresPermissions("blog:blogShareConfig:list")
    @GetMapping("/list")
    public TableDataInfo list(BlogSharesConfig blogSharesConfig)
    {
        startPage();
        List<BlogSharesConfig> list = blogSharesConfigService.selectBlogSharesConfigList(blogSharesConfig);
        return getDataTable(list);
    }

    /**
     * 导出分享类型配置列表
     */
    @RequiresPermissions("blog:blogShareConfig:export")
    @Log(title = "分享类型配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BlogSharesConfig blogSharesConfig)
    {
        List<BlogSharesConfig> list = blogSharesConfigService.selectBlogSharesConfigList(blogSharesConfig);
        ExcelUtil<BlogSharesConfig> util = new ExcelUtil<BlogSharesConfig>(BlogSharesConfig.class);
        util.exportExcel(response, list, "分享类型配置数据");
    }

    /**
     * 获取分享类型配置详细信息
     */
    @RequiresPermissions("blog:blogShareConfig:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(blogSharesConfigService.selectBlogSharesConfigById(id));
    }

    /**
     * 新增分享类型配置
     */
    @RequiresPermissions("blog:blogShareConfig:add")
    @Log(title = "分享类型配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BlogSharesConfig blogSharesConfig)
    {
        return toAjax(blogSharesConfigService.insertBlogSharesConfig(blogSharesConfig));
    }

    /**
     * 修改分享类型配置
     */
    @RequiresPermissions("blog:blogShareConfig:edit")
    @Log(title = "分享类型配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BlogSharesConfig blogSharesConfig)
    {
        return toAjax(blogSharesConfigService.updateBlogSharesConfig(blogSharesConfig));
    }

    /**
     * 删除分享类型配置
     */
    @RequiresPermissions("blog:blogShareConfig:remove")
    @Log(title = "分享类型配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(blogSharesConfigService.deleteBlogSharesConfigByIds(ids));
    }
}
